
from PySide6.QtWidgets import QGraphicsView
from PySide6.QtGui import Qt

class MyGraphicsView(QGraphicsView) :

    def __init__(self, scene, parent = None):
        super().__init__(scene, parent)
        self.__mouseShape = Qt.CursorShape.ArrowCursor  #当鼠标进入视图时就将鼠标设置为 self.__mouseShape 形状
        self.setMouseTracking(True)      # 需要设置视图能追踪鼠标

    def setMouseShape(self, shape):
        self.__mouseShape = shape

    '''重写鼠标移动事件'''
    def mouseMoveEvent(self, event):
        self.setCursor(self.__mouseShape)
        super().mouseMoveEvent(event)

